package com.example.ftp.Service.Impl;

import com.example.ftp.Beans.Document;
import com.example.ftp.Beans.Ftp;
import com.example.ftp.Dao.Impl.FtpDaoImpl;
import com.example.ftp.Service.FtpService;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;

import java.io.IOException;
import java.util.List;

/**
 * @program: FTP
 * @description:
 * @author: LOTP
 * @create: 2022-01-07 15:54
 **/
public class FtpServiceImpl implements FtpService {

    FtpDaoImpl ftpDao = null;

    public FtpServiceImpl(Ftp ftp){
        this.ftpDao = new FtpDaoImpl(ftp);
    }

    @Override
    public FTPClient getFtpClient() {
        return ftpDao.getFtpClient();
    }

    @Override
    public FTPFile[] listFiles(String ftpPath) {
        return ftpDao.listFiles(ftpPath);
    }

    @Override
    public List<Document> getWorkingDirectoryDocuments() {
        return ftpDao.getWorkingDirectoryDocuments();
    }


    @Override
    public boolean downloadFile(String ftpPath, String localPath) {
        return ftpDao.downloadFile(ftpPath,localPath);
    }

    @Override
    public boolean changeToParentDirectory() {
        return ftpDao.changeToParentDirectory();
    }

    @Override
    public boolean upload(String ftpPath, String localPath, boolean isCoverDirectory, boolean isCoverFile) throws Exception {
        return ftpDao.upload(ftpPath, localPath, isCoverDirectory, isCoverFile);
    }

    @Override
    public boolean deleteFile(String filePath) {
        return ftpDao.deleteFile(filePath);
    }

    @Override
    public boolean deleteDirectory(String directoryPath) throws IOException {
        return ftpDao.deleteDirectory(directoryPath);
    }

    @Override
    public boolean makeDirectory(String ftpPath) throws IOException {
        return ftpDao.makeDirectory(ftpPath);
    }

    @Override
    public boolean replaceName(String oldPath, String newPath) throws IOException {
        return ftpDao.replaceName(oldPath, newPath);
    }

    @Override
    public void setHiddenDocument(boolean flag) {
        ftpDao.setHiddenDocument(flag);
    }
}


